package com.example.demo.dto;

import com.example.demo.enums.OrderPriorityEnum;
import com.example.demo.enums.OrderStatusEnum;
import com.example.demo.enums.OrderTypeEnum;
import com.example.demo.enums.PaymentMethodEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;

/**
 * 创建订单请求DTO
 * 
 * 演示功能：
 * 1. 前端传递枚举code值，框架自动转换为枚举对象
 * 2. 参数验证和类型安全
 */
@Data
@ApiModel(description = "创建订单请求")
public class CreateOrderRequest {
    
    @ApiModelProperty(value = "用户ID", required = true)
    @NotNull(message = "用户ID不能为空")
    private Long userId;
    
    @ApiModelProperty(value = "订单状态", example = "1", notes = "通常创建时为1-待支付")
    private OrderStatusEnum status = OrderStatusEnum.PENDING_PAYMENT;
    
    @ApiModelProperty(value = "订单类型", example = "1", required = true, notes = "1-普通订单, 2-预售订单, 3-团购订单, 4-秒杀订单, 5-礼品订单")
    @NotNull(message = "订单类型不能为空")
    private OrderTypeEnum type;
    
    @ApiModelProperty(value = "订单优先级", example = "2", notes = "1-低优先级, 2-普通优先级, 3-高优先级, 4-紧急优先级")
    private OrderPriorityEnum priority = OrderPriorityEnum.NORMAL;
    
    @ApiModelProperty(value = "支付方式", example = "1", notes = "1-支付宝, 2-微信支付, 3-银行卡, 4-信用卡, 5-余额支付, 6-货到付款")
    private PaymentMethodEnum paymentMethod;
    
    @ApiModelProperty(value = "订单总金额", required = true)
    @NotNull(message = "订单金额不能为空")
    @DecimalMin(value = "0.01", message = "订单金额必须大于0")
    private BigDecimal totalAmount;
    
    @ApiModelProperty(value = "收货地址")
    @NotBlank(message = "收货地址不能为空")
    private String shippingAddress;
    
    @ApiModelProperty(value = "收货人姓名")
    @NotBlank(message = "收货人姓名不能为空")
    private String receiverName;
    
    @ApiModelProperty(value = "收货人电话")
    @NotBlank(message = "收货人电话不能为空")
    private String receiverPhone;
    
    @ApiModelProperty(value = "订单备注")
    private String remark;
}
